//==================================================================================
//		Dual Quad Board Program
//		file name : Menu_Page2_Function.C
//		version : 1.0
//		target device : w78e516(winbond)
//		target board : dual quad board
//		c compiler : Keil
//==================================================================================

//void Screen_Position_Setup_Display(U8, U8, U8);
//void Display_Border_Color_Setup_Display();
//void Page2_Sub_Menu_Bar_Display(U8 sub_menu_num);
//void Display_ON_Screen_ON_OFF_Display(U8, U8, U8, U8);
#ifdef VGA_DISPLAY
void Vga_Setup_Display();
void Vga_Setup_Function();
#endif
#if 0
//==================================================================================
//
//
//
//
//
//==================================================================================
void Page2_Sub_Menu_Bar_Display(U8 sub_menu_num)
{
//	U8 display_data_read;
	U8 temp, osd_property, N_P = 0, i;
	
	if(b_video_fmt == NTSC)
		N_P = 12;
	//Clear bottom Title
	WriteOSDClr(PTH_Y,MASTER, 7, (b_video_fmt == NTSC ? 214 :252), 82, 12);
	Up_Down_Font_display();
	Select_Font_display(11);
//	Clear_Font_display(25, 49); 
	if((sub_menu_select_bar == 3)||(sub_menu_select_bar == 4))
	{	
		Left_Right_Font_display(25);
		Adjust_Font_display(29);
//		Clear_Font_display(40, 48);				
	}
	else if(sub_menu_select_bar > 4)
	{				
//		Clear_Font_display(24, 39);     
		Enter_Font_display(40);
	}

	Menu_Exit_Font_display(76);

	temp = sub_menu_select_bar_backup;
	osd_property = OSD_NOR;
	
	for(i = 0; i < 2; i++)
	{
		switch(temp)
		{
			case 1 :
//					display_data_read = I2C_Data_Read(rom_p0, 0x03);		//... Display Setup "Title"		
					Display_ON_Screen_ON_OFF_Display(title_display, 28, 74-N_P, osd_property);
					break;
			case 2 :
//					display_data_read = I2C_Data_Read(rom_p0, 0x04);		//... Display Setup "Title"		
					Display_ON_Screen_ON_OFF_Display(date_display, 42, 74-N_P, osd_property);
					break;
#ifdef VGA_DISPLAY					
			case 3 :
					Screen_Position_Setup_Display(0x87, osd_property, 86-N_P);
					break;
			case 4 :
					Screen_Position_Setup_Display(0x88, osd_property, 98-N_P);
					break;
			case 5 :
			case 6 :
					Vga_Setup_Display();
					break;
#else
			case 3 :
					Screen_Position_Setup_Display(0x87, osd_property, 98-N_P);
					break;
			case 4 :
					Screen_Position_Setup_Display(0x88, osd_property, 110-N_P);
					break;
			case 5 :
			case 6 :
#endif				
			case 7 :
			case 8 :
			case 9:
#ifdef VGA_DISPLAY
			case 10:
			case 11:
#endif				
					Display_Border_Color_Setup_Display();
					break;
			default	:
//					display_data_read = I2C_Data_Read(rom_p0, 0x03);		//... Display Setup "Title"		
					Display_ON_Screen_ON_OFF_Display(title_display, 28, 74-N_P, OSD_BLK);
//					display_data_read = I2C_Data_Read(rom_p0, 0x04);		//... Display Setup "Date/time"		
					Display_ON_Screen_ON_OFF_Display(date_display, 42, 74-N_P, OSD_NOR);	
#ifdef VGA_DISPLAY
					Screen_Position_Setup_Display(0x87, OSD_NOR, 86-N_P);
					Screen_Position_Setup_Display(0x88, OSD_NOR, 98-N_P);
					Vga_Setup_Display();
#else
					Screen_Position_Setup_Display(0x87, OSD_NOR, 98-N_P);
					Screen_Position_Setup_Display(0x88, OSD_NOR, 110-N_P);
#endif
					Display_Border_Color_Setup_Display();
		}
		temp = sub_menu_num;
		osd_property = OSD_BLK;
	}
}
#endif
//==================================================================================
//
//
//
//
//
//==================================================================================
#ifdef VGA_DISPLAY
void Vga_Setup_Display()
{
	U8 i,N_P = 0;
	U8 temp;
	
	if(b_video_fmt == NTSC)
		N_P = 12;

//	buff = (I2C_Data_Read(rom_p0, 0x06)&0xf0)>>4;		//... Vga mode 	0: 800x600_60hz  1:1024x768_60hz 
	for(i = 5; i<7; i++)
	{
		temp = (i == (U8)sub_menu_select_bar) ? OSD_BLK : OSD_NOR;
		WriteOSDFnt(PTH_Y, MASTER, 28+(i-5)*18, 122-N_P, temp, ((i-5) == vga_mode) ? RIDIO_ON_FONT : RIDIO_OFF_FONT);	
	}
}
#endif
#if 0
//==================================================================================
//
//
//
//
//
//==================================================================================
void Display_Border_Color_Setup_Display()
{
	U8 i, buff,N_P = 0;
	U8 temp;
	
	if(b_video_fmt == NTSC)
		N_P = 12;

	buff = I2C_Data_Read(rom_p0, 0x06)&0x0f;		//... Display Setup "Border Color"	1: Black  2: 25% Gray 3: 75% Gray 4: White 5: OFF
#ifdef VGA_DISPLAY
	for(i=7; i<12; i++)
	{
		temp = (i == sub_menu_select_bar) ? OSD_BLK : OSD_NOR;
		WriteOSDFnt(PTH_Y, MASTER, 28, 146+(i-7) *12-N_P, temp, ((i-6) == buff) ? RIDIO_ON_FONT : RIDIO_OFF_FONT);	
	}
#else
	for(i=5; i<10; i++)
	{
		temp = (i == sub_menu_select_bar) ? OSD_BLK : OSD_NOR;
		WriteOSDFnt(PTH_Y, MASTER, 28, 146+(i-5) *12-N_P, temp, ((i-4) == buff) ? RIDIO_ON_FONT : RIDIO_OFF_FONT);	
	}
#endif	
}

//==================================================================================
//
//
//
//
//
//==================================================================================
void Display_ON_Screen_ON_OFF_Display(U8 display_data_read, U8 x_loc, U8 y_loc, U8 osd_property)
{
	WriteOSDFnt(PTH_Y,MASTER,x_loc, y_loc, osd_property, (display_data_read != 0 ? CHECK_BOX_FONT : BLANK_BOX_FONT));	

	if(sub_menu_select_bar < 3)
	{
		if(display_data_read !=0)
			Enable_Font_display(0);
		else
			Enable_Font_display(1);
	}
}

//==================================================================================
//
//
//
//
//
//==================================================================================
void Screen_Position_Setup_Display(U8 read_address, U8 osd_property, U8 y_loc)
{
	U8 screen_pos_read_data , buff, temp;
			
	screen_pos_read_data = I2C_Data_Read(rom_p0, read_address );		//... Screen Position X/Y
/*	if(read_address == 0x87)
	{
		temp = ReadAsicByte(MASTER, DVC_PG1, 0xa8);
		temp &= 0xc0;
		temp |= (screen_pos_read_data << 1);
		WriteAsicByte(ALL_CHIP, DVC_PG1, 0xa8, temp);
	}
	else if(read_address == 0x88)
	{
		temp = ReadAsicByte(MASTER, DVC_PG1, 0xa7);
		temp &= 0xe0;
		temp |= (screen_pos_read_data << 2);
		WriteAsicByte(ALL_CHIP, DVC_PG1, 0xa7, temp);
	}
*/
	if(read_address == 0x87)
		buff = 15;
	else
		buff = 4;

	if(screen_pos_read_data > buff)
	{
		if(read_address == 0x87)
			temp = 25;
		else
			temp = 7;
		
		if(screen_pos_read_data == temp)
			WriteOSDStr(PTH_Y,MASTER, 60, y_loc,osd_property,str_max);
		else
		{
			WriteOSDFnt(PTH_Y,MASTER, 60, y_loc, osd_property, PLUS_FONT);
			WriteOSDFnt(PTH_Y,MASTER, 62, y_loc, osd_property, ((screen_pos_read_data-buff) +ZERO_OFFSET));
			WriteOSDFnt(PTH_Y,MASTER, 64, y_loc, osd_property, BLANK_FONT);
		}	
	}
	else if(screen_pos_read_data < buff)
	{
		if(read_address == 0x87)
			temp = 5;
		else
			temp = 0;
		
		if(screen_pos_read_data == temp)
			WriteOSDStr(PTH_Y,MASTER, 60,y_loc,osd_property,str_min);
		else
		{
			WriteOSDFnt(PTH_Y,MASTER, 60, y_loc, osd_property, MINUS_FONT);
			WriteOSDFnt(PTH_Y,MASTER, 62, y_loc, osd_property, ((buff - screen_pos_read_data) +ZERO_OFFSET));
			WriteOSDFnt(PTH_Y,MASTER, 64, y_loc, osd_property, BLANK_FONT);
		}	
	}
	else
	{
		WriteOSDFnt(PTH_Y,MASTER, 60, y_loc, osd_property, ZERO_OFFSET);
		WriteOSDFnt(PTH_Y,MASTER, 62, y_loc, osd_property, BLANK_FONT);
		WriteOSDFnt(PTH_Y,MASTER, 64, y_loc, osd_property, BLANK_FONT);
	}
}
//==================================================================================
#endif

